<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">

<title>相关角色</title>
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" href="./css/weui.css" />
<link rel="stylesheet" href="./css/example.css" />
<script type="text/javascript" src="./js/jquery-1.11.3.min.js"></script>
<script type="text/javascript">
var storage = window.localStorage;
// 屏蔽屏幕自身手势
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
$(document).ready(function() {
	getRole();
});

function getRole(){
   	$.ajax({
    	url: "./user/getRoles",
	    type: "POST",
 	    data : {
 	       	primaryRole : storage.getItem("primaryRole")
 	    },
 	    dataType: 'json',
 	    cache: false,
 	    success: function (ret) {
			if(ret.resultCode==0){
				var roleHTML="";
    	        $("#roles").html("");
    	        for(var i=0;i<ret.content.length;i++){
    	        	roleHTML += '<a class="weui_cell" href="./jsp/personalCenter/myInfo.jsp?currRole='+ret.content[i].userCode+'&isMainRole='+ret.content[i].isMainRole+'">'
						           	+'<div class="weui_cell_hd"><img src="./images/person1.png" alt="" style="width:25px;height:25px; margin-right:5px;display:block"></div>'
						            +'<div class="weui_cell_bd weui_cell_primary" style="margin-left: 5px;">'
						            	+'<p>'+ret.content[i].userName+'</p>'
						            +'</div>'
					                +'<div class="weui_cell_ft"></div>'
					            +'</a>';
	            
    	        }
	            roleHTML += '<a class="weui_cell" href="./jsp/personalCenter/addPerson.jsp">'
					        +'<div class="weui_cell_bd weui_cell_primary" style="margin-left:48%;">'
					            	+'<img src="./images/Add.png" alt="" style="width:25px;height:25px; margin-right:5px;display:block">'
					            +'</div>'
				            +'</a>';	
    	        $("#roles").html(roleHTML);
			}else{
				alert(ret.msg);
  	       		window.location.href = "./jsp/login.jsp";
			}
       	}
 	});
}
</script>
</head>
<body ontouchstart>
<div class="container js_container"></div>
<h4 style="text-align: center;margin-top: 8px;">相关角色</h4>
<div class="weui_cells weui_cells_access" style="margin-top: 10px;">
	<div id="roles"></div>             
</div>
<!-- <footer style="position: fixed;bottom: 1px;width: 100%;">
	<a class="weui_btn" style="color:#fff;background-color: #337ab7;float: left;width: 50%;border-radius: 0px !important;margin:0px !important;" onclick="addRole()">添加</a>
	<a class="weui_btn" style="color:#fff;background-color: #f43930;float: right;width: 50%;border-radius: 0px !important;margin:0px !important;" onclick="delRole()">删除</a>
</footer>  -->
</body>
</html>
